package com.yowasa.xiuxian.engine.battle.enemy.strategy;

import com.google.common.collect.Lists;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.battle.strategy.BaseSpellStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import com.yowasa.xiuxian.service.helper.BattleHelper;
import com.yowasa.xiuxian.util.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import java.util.Random;

@BS(name = "丘丘王")
@Order(1006)
@Component
public class QiuQiuWang extends BaseSpellStrategy {
    @Autowired
    private BattleHelper battleHelper;

    @Override
    public ElementEnum getElement() {
        return null;
    }

    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        int dmg;
        String desc;
        //user.getElement().get("土") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY
        String start = first.getUserBO().getName().substring(0,2);

        if(Math.random() < 0.75){
            int orgAtk = first.getBattleInfo().getAtk();
            int def = second.getBattleInfo().getDef();
            int atk = (int) (orgAtk * 1.5);
            dmg = battleHelper.calAtk(atk, def);
            desc = start + RandomUtil.choice(Lists.newArrayList("冲刺","坠击","挥击重锤"));
        }else {
            int orgAtk = first.getBattleInfo().getSpell();
            int def = second.getBattleInfo().getRes();
            int atk = (int) (orgAtk * 1.5);
            dmg = battleHelper.calAtk(atk, def);
            desc = start + RandomUtil.choice(Lists.newArrayList("史莱姆投掷"));
        }

        battleHelper.autoAction(this, first, second, content, dmg, desc);
    }

    @Override
    public void limit(UserBO user) {
        throw new HandlerException("无法学习妖兽的攻击手段");
    }

    @Override
    public String limitDesc() {
        return "无";
    }

    @Override
    public String desc() {
        return  "千嶂中漫行的神秘「王者」。被同胞称为「Lawa」的庞大丘丘人。" +
                "[丘丘岩盔王]。环境中增生的岩元素化成了它们身体的一部分，仿佛血肉与皮肤皆由不移的山岩雕琢而成。\n" +
                "[丘丘霜铠王]。锻炼至极致的肉身似乎已和环境中满溢的冰元素相互融合，沉默威严有如北国的冰川。\n" +
                "[丘丘雷兜王]。巨像般的身躯充满了丰富的雷元素，散逸出的元素能量以电气水晶的形式从身体的缝隙中生长出来。\n\n" +
                "擅长物理攻击，但也会借助史莱姆的力量使用法术攻击\n 技能组：冲刺,坠击,挥击重锤,史莱姆投掷\n\n" +
                "出没地点：\t归离原，遁玉陵" ;
    }



}
